package daily.jun0617;

import javax.swing.*;
import java.awt.*;

public class JLabelTest {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(()->createAndShow());
    }
    public static void createAndShow(){
        //1.创建窗体
        JFrame jFrame = new JFrame("标签窗口");
        //2.为窗体设置大小，位置等属性
        jFrame.setBounds(300, 400, 800, 700);
        jFrame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE);
        jFrame.setVisible(true);
        //3.设置窗体布局
        jFrame.setLayout(new BorderLayout());
        //4.创建图标
        ImageIcon imageIcon = new ImageIcon("D:\\Personal Files\\ECS云服务器\\Wordpress\\图片\\00009368.Loading_Tip-16.jpg");
        //5.修改图片大小
        Image image = imageIcon.getImage();
        image = image.getScaledInstance(800,600,Image.SCALE_DEFAULT);
        imageIcon.setImage(image);

        //6.创建图片标签
        JLabel imageLabel = new JLabel();
        imageLabel.setIcon(imageIcon);

        //7.创建文本标签
        JLabel textLabel = new JLabel("二次元小姐姐", JLabel.CENTER);

        //8.向JFrame窗口添加标签
        jFrame.add(imageLabel,BorderLayout.PAGE_START);
        jFrame.add(textLabel,BorderLayout.PAGE_END);
    }
}
